package com.itheima.admin.controller;

import com.itheima.admin.Service.AdchannelService;
import com.itheima.apis.admin.AdChannelControllerApi;
import com.itheima.model.common.admin.dtos.ChannelDto;
import com.itheima.model.common.admin.pojos.AdChannel;
import com.itheima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/channel")
public class AdChannelController implements AdChannelControllerApi {
    @Autowired
    private AdchannelService adchannelService;
    @PostMapping("/list")
    @Override
    public ResponseResult findbyNameAndPage(@RequestBody ChannelDto channelDto) {
        ResponseResult responseResult = adchannelService.findbyNameAndPage(channelDto);
        return responseResult;
    }
    @PostMapping("/save")
    @Override
    public ResponseResult insert(@RequestBody AdChannel adChannel) {
        return adchannelService.insert(adChannel);
    }
    @PostMapping("/update")
    @Override
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return adchannelService.update(adChannel);
    }
    @GetMapping("/del/{id}")
    @Override
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adchannelService.deleteById(id);
    }
}
